


@propertyWrapper
struct WrapperTest {
    internal var innerValue: Int {
        didSet {
            print("didSet called \(oldValue)")
        }
        willSet {
            print("willSet called \(newValue)")
        }
    }
    public var wrappedValue: Int {
        get {
            return innerValue
        }
        set {
            innerValue = min(50, newValue)
            print("setter called")
        }
    }
    // 装饰器的初始化器，可以初始默认值
    init(wrappedValue initialValue: Int) {
        self.innerValue = 0
        self.wrappedValue = initialValue
    }
}

struct WrapperTestDemo {
    @WrapperTest(wrappedValue: 55) var demo1: Int
    @WrapperTest() var demo2: Int = 88
}


func test22() {
    
    
    
    let demo = WrapperTestDemo()
    print(demo.demo1)
    print(demo.demo2)
    
    
}
